#ifndef OBSERVER_H
#define OBSERVER_H
#include <iostream>
#include <vector>
#include "javabean.h"

using namespace std;
class Secretary;

class PlayObserver{
    PropertyBuilderByName(string,name,private)
    PointerPropertyBuilderByName(Secretary,secretary,private)
    PlayObserver(string name,Secretary* secretary):m_name(name),m_secretary(secretary){
    }
public:
    void udpate(string action){
        cout<<"观察者受到action:"<<action<<endl;
    }
};


class Secretary{
    PropertyBuilderByName(string,action,private)
    PointerPropertyBuilderByName(vector<PlayObserver*>,observers,private)

    void addObserver(PlayObserver* observer){
        this->m_observers->push_back(observer);
    }
    void Notify(string action){
        for(vector<PlayObserver*>::iterator it=this->m_observers->begin();it!=m_observers->end();it++){
            (*it)->udpate(action);
        }
    }
};



#endif // OBSERVER_H
